/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aal.model;

import com.aal.business.WarehouseIOManagementLocal;
import com.aal.business.WarehouseManagementLocal;
import com.aal.entity.Product;
import com.aal.entity.Warehouse;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author quy
 */
public class WarehouseManagement {
    WarehouseIOManagementLocal warehouseIOManagement = lookupWarehouseIOManagementLocal();
    WarehouseManagementLocal warehouseManagement = lookupWarehouseManagementLocal();
    private String warehouseName;
    private String warehouseLocation;
    private String warehouseDescription;
    private String hidden;
    private com.aal.entity.Product product;

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }
    
    public String getHidden() {
        return hidden;
    }

    public void setHidden(String hidden) {
        this.hidden = hidden;
    }
    public String getWarehouseDescription() {
        return warehouseDescription;
    }

    public void setWarehouseDescription(String warehouseDescription) {
        this.warehouseDescription = warehouseDescription;
    }

    public String getWarehouseLocation() {
        return warehouseLocation;
    }

    public void setWarehouseLocation(String warehouseLocation) {
        this.warehouseLocation = warehouseLocation;
    }

    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }
    public boolean getCreateWarehouse()
    {
        return warehouseManagement.createWarehouse(warehouseName, warehouseLocation, warehouseDescription);
    }
    public boolean getEditWarehouse(){
        return warehouseManagement.editWarehouse( warehouseName, warehouseLocation, warehouseDescription);
    }
    public boolean getDeleteWarehouse(){
        return warehouseManagement.deleteWarehouse(warehouseName);
    }
    public List<Warehouse> getWarehouseByName(){
        return warehouseManagement.findWarehouse(warehouseName);
    }
    public List<Warehouse> getAllWarehouses() {
        return warehouseManagement.getAllWarehouses();
    }
    private WarehouseManagementLocal lookupWarehouseManagementLocal() {
        try {
            Context c = new InitialContext();
            return (WarehouseManagementLocal) c.lookup("java:global/AAL/AAL-ejb/WarehouseManagement!com.aal.business.WarehouseManagementLocal");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    private WarehouseIOManagementLocal lookupWarehouseIOManagementLocal() {
        try {
            Context c = new InitialContext();
            return (WarehouseIOManagementLocal) c.lookup("java:global/AAL/AAL-ejb/WarehouseIOManagement!com.aal.business.WarehouseIOManagementLocal");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
    
}
